; ModuleID = 'worlk_in_group01.c'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-pc-linux-gnu"

%struct..0anon = type { i32, i32, i32 }
%struct.MPI_Status = type { i32, i32, i32, i32, i32 }
%struct.ompi_communicator_t = type opaque
%struct.ompi_datatype_t = type opaque
%struct.ompi_predefined_communicator_t = type opaque
%struct.ompi_predefined_datatype_t = type opaque

@ompi_mpi_comm_world = external global %struct.ompi_predefined_communicator_t ; <%struct.ompi_predefined_communicator_t*> [#uses=1]
@ompi_mpi_int = external global %struct.ompi_predefined_datatype_t ; <%struct.ompi_predefined_datatype_t*> [#uses=1]
@.str = private constant [37 x i8] c"P:%d received coordsare (%d,%d,%d) \0A\00", align 1 ; <[37 x i8]*> [#uses=1]

define i32 @main(i32 %argc, i8** %argv) nounwind {
entry:
  %argc_addr = alloca i32                         ; <i32*> [#uses=2]
  %argv_addr = alloca i8**                        ; <i8***> [#uses=2]
  %retval = alloca i32                            ; <i32*> [#uses=1]
  %ptype = alloca %struct.ompi_datatype_t*        ; <%struct.ompi_datatype_t**> [#uses=4]
  %point = alloca %struct..0anon                  ; <%struct..0anon*> [#uses=8]
  %status = alloca %struct.MPI_Status             ; <%struct.MPI_Status*> [#uses=1]
  %rank = alloca i32                              ; <i32*> [#uses=4]
  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
  store i32 %argc, i32* %argc_addr
  store i8** %argv, i8*** %argv_addr
  %0 = call i32 @MPI_Init(i32* %argc_addr, i8*** %argv_addr) nounwind ; <i32> [#uses=0]
  %1 = call i32 @MPI_Comm_rank(%struct.ompi_communicator_t* bitcast (%struct.ompi_predefined_communicator_t* @ompi_mpi_comm_world to %struct.ompi_communicator_t*), i32* %rank) nounwind ; <i32> [#uses=0]
  %2 = call i32 @MPI_Type_contiguous(i32 3, %struct.ompi_datatype_t* bitcast (%struct.ompi_predefined_datatype_t* @ompi_mpi_int to %struct.ompi_datatype_t*), %struct.ompi_datatype_t** %ptype) nounwind ; <i32> [#uses=0]
  %3 = call i32 @MPI_Type_commit(%struct.ompi_datatype_t** %ptype) nounwind ; <i32> [#uses=0]
  %4 = load i32* %rank, align 4                   ; <i32> [#uses=1]
  %5 = icmp eq i32 %4, 3                          ; <i1> [#uses=1]
  br i1 %5, label %bb, label %bb2

bb:                                               ; preds = %entry
  %6 = getelementptr inbounds %struct..0anon* %point, i32 0, i32 0 ; <i32*> [#uses=1]
  store i32 15, i32* %6, align 4
  %7 = getelementptr inbounds %struct..0anon* %point, i32 0, i32 1 ; <i32*> [#uses=1]
  store i32 23, i32* %7, align 4
  %8 = getelementptr inbounds %struct..0anon* %point, i32 0, i32 2 ; <i32*> [#uses=1]
  store i32 6, i32* %8, align 4
  %9 = load %struct.ompi_datatype_t** %ptype, align 4 ; <%struct.ompi_datatype_t*> [#uses=1]
  %point1 = bitcast %struct..0anon* %point to i8* ; <i8*> [#uses=1]
  %10 = call i32 @MPI_Send(i8* %point1, i32 1, %struct.ompi_datatype_t* %9, i32 1, i32 52, %struct.ompi_communicator_t* bitcast (%struct.ompi_predefined_communicator_t* @ompi_mpi_comm_world to %struct.ompi_communicator_t*)) nounwind ; <i32> [#uses=0]
  br label %bb5

bb2:                                              ; preds = %entry
  %11 = load i32* %rank, align 4                  ; <i32> [#uses=1]
  %12 = icmp eq i32 %11, 1                        ; <i1> [#uses=1]
  br i1 %12, label %bb3, label %bb5

bb3:                                              ; preds = %bb2
  %13 = load %struct.ompi_datatype_t** %ptype, align 4 ; <%struct.ompi_datatype_t*> [#uses=1]
  %point4 = bitcast %struct..0anon* %point to i8* ; <i8*> [#uses=1]
  %14 = call i32 @MPI_Recv(i8* %point4, i32 1, %struct.ompi_datatype_t* %13, i32 3, i32 52, %struct.ompi_communicator_t* bitcast (%struct.ompi_predefined_communicator_t* @ompi_mpi_comm_world to %struct.ompi_communicator_t*), %struct.MPI_Status* %status) nounwind ; <i32> [#uses=0]
  %15 = getelementptr inbounds %struct..0anon* %point, i32 0, i32 2 ; <i32*> [#uses=1]
  %16 = load i32* %15, align 4                    ; <i32> [#uses=1]
  %17 = getelementptr inbounds %struct..0anon* %point, i32 0, i32 1 ; <i32*> [#uses=1]
  %18 = load i32* %17, align 4                    ; <i32> [#uses=1]
  %19 = getelementptr inbounds %struct..0anon* %point, i32 0, i32 0 ; <i32*> [#uses=1]
  %20 = load i32* %19, align 4                    ; <i32> [#uses=1]
  %21 = load i32* %rank, align 4                  ; <i32> [#uses=1]
  %22 = call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds ([37 x i8]* @.str, i32 0, i32 0), i32 %21, i32 %20, i32 %18, i32 %16) nounwind ; <i32> [#uses=0]
  br label %bb5

bb5:                                              ; preds = %bb3, %bb2, %bb
  %23 = call i32 @MPI_Finalize() nounwind         ; <i32> [#uses=0]
  br label %return

return:                                           ; preds = %bb5
  %retval6 = load i32* %retval                    ; <i32> [#uses=1]
  ret i32 %retval6
}

declare i32 @MPI_Init(i32*, i8***)

declare i32 @MPI_Comm_rank(%struct.ompi_communicator_t*, i32*)

declare i32 @MPI_Type_contiguous(i32, %struct.ompi_datatype_t*, %struct.ompi_datatype_t**)

declare i32 @MPI_Type_commit(%struct.ompi_datatype_t**)

declare i32 @MPI_Send(i8*, i32, %struct.ompi_datatype_t*, i32, i32, %struct.ompi_communicator_t*)

declare i32 @MPI_Recv(i8*, i32, %struct.ompi_datatype_t*, i32, i32, %struct.ompi_communicator_t*, %struct.MPI_Status*)

declare i32 @printf(i8* noalias, ...) nounwind

declare i32 @MPI_Finalize()
